import axios from "axios";
import Nprogress from "nprogress";
import 'nprogress/nprogress.css'

const request = axios.create({
    baseURL: '/api',
    timeout: 10000
})

// 添加请求拦截器
request.interceptors.request.use(function (config) {
    // 一般用于添加token凭证
    Nprogress.start()
    return config;
});

// 添加响应拦截器
request.interceptors.response.use(function (response) {
    Nprogress.done()
    // 数据去壳
    return response.data;
}, function (error) {
    console.log(error);
    Nprogress.done()
    return new Promise(() => { })
});


export default request